package tech.wowo.controller;

import lombok.extern.log4j.Log4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tech.wowo.pojo.Candidate;
import tech.wowo.pojo.User;
import tech.wowo.service.CandidateService;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author: ShanYuqing
 * @Version: v1.0
 */
@RestController
@RequestMapping("candidate")
@Log4j
public class CandidateController {

    @Autowired
    private CandidateService candidateService;


@RequestMapping("/List")
    public Map<String,Object> getCandidateList(){
    log.info("----CandidateServiceImpl---getCandidate method--");
        Map<String,Object> result = new HashMap<>();

       List<Candidate> candidateList = candidateService.getCandidateList();
        result.put("message","200");
        result.put("candidateList",candidateList);

        return result;


    }

    @RequestMapping("/Add")
    public Map<String,Object> addCandidate(Candidate candidate){
        log.info("----CandidateServiceImpl---getCandidate method--");
        Map<String,Object> result = new HashMap<>();

      Integer i =candidateService.addCandidate(candidate);
        result.put("message","200");
        result.put("i",i);

        return result;


    }

}
